<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html" ; charset="utf-8" />
    <title>新增用户</title>
    <link href="../../../css/main.css" rel="stylesheet" type="text/css">
    <link href="../../../layer_v2.1/layer/skin/layer.css" rel="stylesheet" type="text/css">
    <link href="../../../bstable/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="../../../bstable/css/bootstrap-table.css" rel="stylesheet" type="text/css">
</head>

<body>
    <div class="form-con">
        <div>
            <a class="find_a">手机：</a>
            <input id="phone" maxlength="11" type="text" class="form_input text_ient" placeholder="请输入手机号" />
        </div>
        <div>
            <a class="find_a">姓名：</a>
            <input id="name" maxlength="20" type="text" class="form_input text_ient" placeholder="请输入姓名" />
        </div>
        <div>
            <a class="find_a">年龄：</a>
            <input id="age" maxlength="3" type="text" class="form_input text_ient" placeholder="请输入年龄" />
        </div>
        <div>
            <a class="find_a">职务：</a>
            <select id="zhiwu" class="form_input">
                <!-- <option value="1">管理员</option> -->
                <option value="2">教务主管</option>
                <option value="21">教务学历</option>
                <option value="22">教务培训</option>
                <option value="23">教务职业</option>
                <option value="24">教务职称</option>
                <option value="3">财务</option>
                <option value="4">招生老师</option>
                <option value="5">业务主管</option>
            </select>
        </div>
        <input type="button" value="确认" class="but_find" id="btn" style="width: 240px;position: relative;left: 27px;" />
    </div>
    <script src="../../../js/jquery.js"></script>
    <script src="../../../js/common.js"></script>
    <script src="../../../js/date/js/laydate.js"></script>
    <script src="../../../layer_v2.1/layer/layer.js"></script>
    <script src="../../../bstable/js/bootstrap.min.js"></script>

    <script type="text/javascript">
        localStorage.setItem('name', '教务管理/用户新增')
        $('#btn').on('click', function() {
            var phone = $('#phone').val()
            var name = $('#name').val()
            var age = $('#age').val()
            var zhiwu = $('#zhiwu').val()
            var pwd = $('#pwd').val()

            if (!phone) {
                return alert('请输入手机号');
            }
            if (!(/^1[3456789]\d{9}$/.test(phone))) {
                return alert('请输入正确的手机号');
            }
            if (!name) {
                return alert('请输入姓名');
            }
            // if (!age) {
            //     return alert('请输入年龄');
            // }
            if (!zhiwu) {
                return alert('请选择职务');
            }

            $.ajax({
                type: "POST",
                url: baseUrl + 'user/register',
                data: {
                    mobile: phone,
                    realName: name,
                    age: age,
                    perm: zhiwu
                },
                headers: {
                    "Authorization": JSON.parse(localStorage.getItem('userInfo')).token
                },
                dataType: "json",
                success: function(data) {
                    alert(data.message)
                },
                error(err) {
                    console.log(err.responseText)
                    alert(JSON.parse(err.responseText).message)
                }
            });

        })
    </script>
</body>

</html>